//在本地开启一个服务器 用来接受前端请求和前端数据
let express = require('express')
let app = express()
let cors = require('cors')
let port = 3001
app.listen(port, () => {
  console.log('server is running on port ' + port)
})
app.use(cors())
let bodyParser = express.json()
app.use(bodyParser)
//需要将public目录下的文件视为静态资源 而不是借口
//   let static = express.static(path.resolve(__dirname, "../public"));
//   app.use(static);
//处理管理员的路由
try {
  app.use('/api/accounts', require('./routes/accounts'))
  app.use('/api/commonUsers', require('./routes/commonUsers'))
  app.use('/api/admins', require('./routes/admins'))
  app.use('/api/managers', require('./routes/managers'))
  app.use('/api/notices', require('./routes/notices'))
  app.use('/api/token', require('./routes/token'))
  app.use('/api/events', require('./routes/events'))
} catch (err) {
  console.error('路由加载失败', err)
}
